package com.lepinwenhua.roomdemo;

import android.app.Application;

import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;

/**
 * @author: 魏从响
 * @date: 2025/10/27
 * @class: FruitViewModelFactory
 */
public class FruitViewModelFactory implements ViewModelProvider.Factory {
    private Application application;

    public FruitViewModelFactory(Application application) {
        this.application = application;
    }

    @Override
    public <T extends ViewModel> T create(Class<T> modelClass) {
        if (modelClass.isAssignableFrom(FruitViewModel.class)) {
            return (T) new FruitViewModel(application);
        }
        throw new IllegalArgumentException("Unknown ViewModel class");
    }
}

